package com.cloudlead.fleetAction.action;

import com.cloudlead.common.lang.annotation.Label;
import com.cloudlead.common.lang.persistence.EasyuiGridData;
import com.cloudlead.common.worker.action.impl.AbstractActionFactory;
import com.cloudlead.common.worker.annotation.Action;
import com.cloudlead.common.worker.annotation.Order;
import com.cloudlead.fleetAction.BusinessModules;
import com.cloudlead.fleetAction.service.BaseOilCardEditSer;
import com.cloudlead.fleetService.BaseOilCardEditService;
import com.cloudlead.fleetService.vo.BaseOilCardVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.validation.constraints.NotNull;

/**
 * Created by Jinnoo on 2015/8/12.
 */
@Controller
public class BaseOilCardEditActionFactory extends AbstractActionFactory implements BaseOilCardEditService {
    public BaseOilCardEditActionFactory( ) {
        super(BusinessModules.BaseOilCardEdit);
    }

    @Autowired
    BaseOilCardEditSer baseOilCardEditSer;

    @Action
    @Order(1)
    @Label("创建油卡")
    public void createOildCard(@Label("基础数据")BaseOilCardVo vo) {
        baseOilCardEditSer.createOildCard(vo);
    }

    @Action
    @Order(2)
    @Label("编辑油卡")
    public void editOildCard(@Label("基础数据")BaseOilCardVo vo) {
        baseOilCardEditSer.editOildCard(vo);
    }

    @Action
    @Order(3)
    @Label("单值查询")
    public BaseOilCardVo findOneOilCard(@Label("基础数据")BaseOilCardVo vo) {
        return baseOilCardEditSer.findOneOilCard(vo);
    }

    @Action
    @Order(4)
    @Label("多值查询")
    public EasyuiGridData findAllOilCard(@NotNull @Label("基础数据") BaseOilCardVo vo,  @Label("页数")int page,@Label("条数") int rows) {
        return new EasyuiGridData(baseOilCardEditSer.findAllOilCard(vo,page,rows),
                "accountNumber,licencePlate,comment,date,endMoney,flag,id,number,startMoney,status,type,user,baseCompany" +
                        "baseCompany.id companyId," +
                        "baseCompany.companyName companyName," );
    }

    @Action
    @Order(5)
    @Label("删除油卡")
    public void delOilCard(@Label("油卡ID")String id) {
        baseOilCardEditSer.delOilCard(id);
    }
}
